
import { useRequest } from "ahooks";
/**
 * A custom hook for handling polling with a given function.
 * @param fn 需要轮询的函数
 * @param time 多久轮询一次
 * @returns an array containing the run and cancel functions
 */
export const useHanldPolling  = (fn:any,time=4000) =>{
    const { run, cancel,error:_ } = useRequest(fn, {
        pollingInterval: time,
        pollingWhenHidden: false,
        manual: true
      });

      return  [run,cancel]

}